home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 352_01 / wfvfile.cpp < prev    next >
C/C++ Source or Header  |  1991-04-22  |  810b  |  33 lines

  1. /* WFVFILE.C
  2.  *        form validation routine for file names
  3.  *        allows wildcards (list of matching files will be displayed to user).
  4.  *
  5.  *        PARAMETERS: WFORM *form = ptr to form entry table for this data item
  6.  *                    char *buffer= ptr to filename.ext string, at least 13 bytes.
  7.  *        RETURNS: 0 if filename is valid.
  8.  *                 -1 if filename not valid.
  9.  */
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <sys\stat.h>
  13. #include "wtwg.h"
  14. #include "dblib.h"
  15.  
  16.  
  17. int     wfvfile (WFORM *form, char *buffer)
  18.     {
  19.     int retcode = 0;
  20.     struct stat statbuf;
  21.     
  22.     if ( strcspn (buffer, "*?") )
  23.         {
  24.         wildfile_pick ( buffer, 0 );
  25.         }
  26.     
  27.     if (  ( *buffer == 0 ) || ( -1 == stat (buffer, &statbuf) ) )
  28.         {
  29.         wform_showerror ( form, "file not found" );
  30.         retcode = -1;
  31.         }
  32.     return (retcode);    /* wfvfile() */
  33.     }